/*
 * @Author: Star linxinh@qq.com
 * @Date: 2023-04-04 09:35:41
 * @LastEditors: Star linxinh@qq.com
 * @LastEditTime: 2023-04-04 10:49:15
 * @FilePath: \LOG\module_debug.c
 * @Description: 这是默认设置,请设置`customMade`, 打开koroFileHeader查看配置 进行设置: https://github.com/OBKoro1/koro1FileHeader/wiki/%E9%85%8D%E7%BD%AE
 */
#include <stdio.h>
#include <string.h>
#include <unistd.h>
#include <sys/types.h>
#include <sys/stat.h>
#include <fcntl.h>

#include <stdarg.h>

#include "module_debug.h"

int g_current_dbg_level = LOG_LEVEL_DEBUG;

void log_fun(int level, const char *opt, const char *tag, int line, const char *func, const char *fmt, ...)
{
    if (level > g_current_dbg_level)
    {
        char msg_buf[20 * 1024];
        va_list ap;
        va_start(ap, fmt);
        sprintf(msg_buf, "%s/%s (%d): %s()", opt, tag, line, func);
        vsprintf(msg_buf + strlen(msg_buf), fmt, ap);
        fprintf(stderr, "%s\n", msg_buf);
        va_end(ap);
    }
}

void ModuleDebugInit(int level)
{
    g_current_dbg_level = level;
}
